<%--
  Created by IntelliJ IDEA.
  User: nico
  Date: 05/11/12
  Time: 14:48
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript" src="<s:url value="/js/jquery/jquery.collapse.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jquery/jquery.blockUI.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/ongoing.js"/>"></script>

<h5>Ongoing</h5>

<s:if test="!listOngoing.isEmpty()">
    <div id="table_content">
        <table>
            <tr>
                <th>Principal Investigator</th>
                <th>Status</th>
                <th>Activation</th>
                <th>Closure</th>
                <th>Edit</th>
                <th>View</th>
            </tr>
            <tbody id="listOngoing">
                <s:iterator value="listOngoing">
                    <tr>
                        <th><s:property value="%{investigadorProtocoloCentro.principalInvestigator.nombre}"/> <s:property value="%{investigadorProtocoloCentro.principalInvestigator.apellido}"/></th>
                        <th><s:property value="%{investigadorProtocoloCentro.protocoloCentro.centro.status}"/></th>
                        <th><s:property value="%{siteActivation}"/></th>
                        <th><s:property value="%{siteClosure}"/></th>

                        <th>
                            <s:form id="edit" action="main">
                                <s:hidden value="%{id}" name="editableId" />
                                <a onclick="$(this).closest('form').submit()"><img src="<s:url value="/images/edit.png"/>" title="Edit" alt="Edit"></a>
                            </s:form>
                        </th>
                        <th>
                            <s:form id="view" action="main">
                                <s:hidden value="%{id}" name="editableId" />
                                <s:hidden value="true" name="view" />
                                <a onclick="$(this).closest('form').submit()"><img src="<s:url value="/images/eye.png"/>" title="View" alt="View"></a>
                            </s:form>
                        </th>
                        <th><s:hidden value="%{investigadorProtocoloCentro.principalInvestigator.id}"/></th>
                    </tr>
                </s:iterator>
            <tbody>
        </table>
    </div>
</s:if>

<div id="filter"  class="tableFilter" >
    <s:form id="formEdit" cssClass="tableFilter" cssStyle="width: 750px; table-layout:fixed">
        <table style="width: 75%; margin: 0 auto">
            <s:hidden name="ongoing.id" value="%{ongoing.id}" id="ongoingHidden"/>
            <s:url var="urlGetSite" action="getSiteName" namespace="/Protocols/Ongoing"/>
            <tr><td width="260px"></td><td width="300px"></td></tr>
            <s:select label="Principal Investigator" id="principalInvestigator" name="investigatorId"
                      headerKey="-1" headerValue="Choose an Investigator"
                      list="listPrincipalInvestigators" value="%{ongoing.investigadorProtocoloCentro.principalInvestigator.id}"
                      onchange="$('#ongoingHidden').val(''); checkInvestigator(this.value, '%{urlGetSite}');"/>
            <s:textfield label="Site Name" id="siteName" disabled="true"
                         value="%{ongoing.investigadorProtocoloCentro.protocoloCentro.centro.institucion}"/>
            <s:textfield label="Site Status" id="siteStatus" disabled="true"
                         value="%{ongoing.investigadorProtocoloCentro.protocoloCentro.centro.status}"/>

            <s:hidden  name="ongoing.initialPackageSent" id="altinitialPackageSent" value="%{ongoing.initialPackageSent}"/>
            <s:textfield label="Initial Package Sent" id="initialPackageSent" cssClass="datepicker"/>

            <s:hidden  name="ongoing.preStudyEvaluationVisit" id="altpreStudyEvaluationVisit" value="%{ongoing.preStudyEvaluationVisit}"/>
            <s:textfield label="Pre-study evaluation visit" id="preStudyEvaluationVisit" cssClass="datepicker"/>

            <s:hidden  name="ongoing.siteApprovedHUM" id="altsiteApprovedHUM" value="%{ongoing.siteApprovedHUM}"/>
            <s:textfield label="Site Approved by HUM" id="siteApprovedHUM" cssClass="datepicker"/>

            <s:hidden  name="ongoing.siv" id="altsiv" value="%{ongoing.siv}"/>
            <s:textfield label="SIV" id="siv" cssClass="datepicker"/>
            <tr><td colspan="2">
                <div id="approvals-show-hide" style="width: 100%">
                    <h2 style="width: 440px">Approvals</h2>
                    <div id="selected-ongoing-approvals" style="margin-bottom: 5px;">
                        <table style="width: 100%">
                            <tr><td width="260px"></td><td width="300px"></td></tr>
                            <s:hidden  name="ongoing.submissionMOH" id="altsubmissionMOH" value="%{ongoing.submissionMOH}"/>
                            <s:textfield label="MOH Submission" id="submissionMOH" cssClass="datepicker"/>
                            <s:hidden  name="ongoing.approvalMOH" id="altapprovalMOH" value="%{ongoing.approvalMOH}"/>
                            <s:textfield label="MOH Approval" id="approvalMOH" cssClass="datepicker"/>
                            <s:hidden  name="ongoing.submissionFEFYM" id="altsubmissionFEFYM" value="%{ongoing.submissionFEFYM}"/>
                            <s:textfield label="FEFYM Submission" id="submissionFEFYM" cssClass="datepicker"/>
                            <s:hidden  name="ongoing.approvalFEFYM" id="altapprovalFEFYM" value="%{ongoing.approvalFEFYM}"/>
                            <s:textfield label="FEFYM Approval" id="approvalFEFYM" cssClass="datepicker"/>
                            <s:select label="Local Approved By" id="localApproved"  onchange="localApprovedCheck(this.value)" headerKey="" headerValue=""
                                      list="localApprovedBy" name="ongoing.localApproved" value="%{ongoing.localApproved}"/>
                            <s:textfield label="Other" id="otherLocalApproved" name="ongoing.otherLocalApproved" value="%{ongoing.otherLocalApproved}"/>
                            <s:hidden  name="ongoing.submissionLocal" id="altsubmissionLocal" value="%{ongoing.submissionLocal}"/>
                            <s:textfield label="Local Submission" id="submissionLocal" cssClass="datepicker"/>
                            <s:hidden  name="ongoing.approvalLocal" id="altapprovalLocal" value="%{ongoing.approvalLocal}"/>
                            <s:textfield label="Local Approval" id="approvalLocal" cssClass="datepicker"/>
                            <s:hidden  name="ongoing.localApprovalFile" id="altlocalApprovalFile" value="%{ongoing.localApprovalFile}"/>
                            <s:textfield label="Local Approval File" id="localApprovalFile" cssClass="datepicker"/>
                        </table>
                    </div>
                </div>
            </td></tr>
        <tr><td colspan="2">
            <div id="followup-show-hide" style="width: 100%">
                <h2 style="width: 440px">Follow Up</h2>
                <div id="selected-ongoing-followup" style="margin-bottom: 5px;">
                    <table style="width: 100%">
                        <tr><td width="260px"></td><td width="300px"></td></tr>
                        <s:hidden  name="ongoing.ctpComplete" id="altctpComplete" value="%{ongoing.ctpComplete}"/>
                        <s:textfield label="CTP Complete" id="ctpComplete" cssClass="datepicker"/>
                        <s:hidden  name="ongoing.siteActivation" id="altsiteActivation" value="%{ongoing.siteActivation}"/>
                        <s:textfield label="Site Activation" id="siteActivation" cssClass="datepicker"/>
                        <s:textfield label="Planned Patients Enrolled"  disabled="true" id="plannedPtsEnrolled" value="%{plannedPtsEnrolled}"/>
                        <s:textfield label="Actual Patients Enrolled" name="ongoing.actualPtsEnrolled" id="actualPtsEnrolled" value="%{ongoing.actualPtsEnrolled}"/>
                        <s:textfield label="Planned Patients Randomized" disabled="true" id="plannedPtsRandomized" value="%{plannedPtsRandomized}"/>
                        <s:textfield label="Actual Patients Randomized" name="ongoing.actualPtsRandomized" id="actualPtsRandomized" value="%{ongoing.actualPtsRandomized}"/>
                        <s:textfield label="Actual Patients Active" name="ongoing.actualPtsActive" id="actualPtsActive" value="%{ongoing.actualPtsActive}"/>
                        <s:hidden  id="altplannedFPFV" value="%{plannedFPFV}"/>
                        <s:textfield label="Planned FPFV (Country)" id="plannedFPFV" disabled="true" cssClass="datepicker"/>
                        <s:hidden  name="ongoing.plannedFPFVSite" id="altplannedFPFVSite" value="%{ongoing.plannedFPFVSite}"/>
                        <s:textfield label="Planned FPFV (Site)" id="plannedFPFVSite" cssClass="datepicker"/>
                        <s:hidden  name="ongoing.actualFpfv" id="altactualFpfv" value="%{ongoing.actualFpfv}"/>
                        <s:textfield label="Actual FPFV" id="actualFpfv" cssClass="datepicker"/>
                        <s:hidden  id="altplannedLPFV" value="%{plannedLPFV}"/>
                        <s:textfield label="Planned LPFV" id="plannedLPFV" disabled="true" cssClass="datepicker"/>
                        <s:hidden  name="ongoing.actualLpfv" id="altactualLpfv" value="%{ongoing.actualLpfv}"/>
                        <s:textfield label="Actual LPFV" id="actualLpfv" cssClass="datepicker"/>
                        <s:hidden  id="altplannedLPLV" value="%{plannedLPLV}"/>
                        <s:textfield label="Planned LPLV" disabled="true" id="plannedLPLV" cssClass="datepicker"/>
                        <s:hidden  name="ongoing.actualLplv" id="altactualLplv" value="%{ongoing.actualLplv}"/>
                        <s:textfield label="Actual LPLV" id="actualLplv" cssClass="datepicker"/>
                        <s:hidden  name="ongoing.siteClosure" id="altsiteClosure" value="%{ongoing.siteClosure}"/>
                        <s:textfield label="Site Closure" id="siteClosure" cssClass="datepicker"/>
                        <s:select label="Special Recruitment Actions?" name="ongoing.specialRecruitmentActions" id="specialRecruitmentActions"  value="%{ongoing.specialRecruitmentActions}"
                                  list="#{'YES':'YES', 'NO':'NO'}" onchange="specialRecruitmentActionsCheck(this.value)"/>
                        <s:textarea label="Recruitment Actions Description" name="ongoing.recruitmentActionsDescription" id="recruitmentActionsDescription" value="%{ongoing.recruitmentActionsDescription}"/>
                    </table>
                </div>
            </div>
        </td></tr>
        <tr><td colspan="2">
            <div id="inspection-show-hide" style="width: 100%">
                <h2 style="width: 440px">Inspection / Audit</h2>
                <div id="selected-ongoing-inspection" style="margin-bottom: 5px;">
                    <table style="width: 100%">
                        <tr><td width="260px"></td><td width="300px"></td></tr>
                        <s:select label="Inspection?" name="ongoing.inspection" id="inspection"  value="%{ongoing.inspection}"
                                  list="#{'YES':'YES', 'NO':'NO'}" onchange="inspectionCheck(this.value)"/>
                        <s:select label="MOH?" name="ongoing.inspectionMOH" id="inspectionMOH"  value="%{ongoing.inspectionMOH}"
                                  list="inspectionsMOH"/>
                        <s:select label="Action" name="ongoing.inspectionAction" id="inspectionAction"  value="%{ongoing.inspectionAction}"
                                  list="inspectionActions"/>
                        <s:select label="BMS Audit?" name="ongoing.bmsAudit" id="bmsAudit"  value="%{ongoing.bmsAudit}"
                                  list="#{'YES':'YES', 'NO':'NO'}" onchange="bmsAuditCheck(this.value)"/>
                        <s:select label="Outcome" name="ongoing.outcomeBms" id="outcomeBms"  value="%{ongoing.outcomeBms}"
                                  list="outcomes"/>
                        <s:select label="EC Audit?" name="ongoing.ecAudit" id="ecAudit"  value="%{ongoing.ecAudit}"
                                  list="#{'YES':'YES', 'NO':'NO'}" onchange="ecAuditCheck(this.value)"/>
                        <s:select label="Outcome" name="ongoing.outcomeEc" id="outcomeEc"  value="%{ongoing.outcomeEc}"
                                  list="outcomes"/>
                    </table>
                </div>
            </div>
        </td></tr>


        <tr>
            <td colspan="2">
                Last modified:
                <s:if test="ongoing.lastModification != null">
                    <s:property value="%{ongoing.lastModification}"/>
                </s:if>
                <s:else>
                    N/A
                </s:else>
            </td>
        </tr>


        <tr>
            <td style="text-align: center">
                <s:submit value="Save" id="save" onclick="validateOngoing();" action="save" theme="simple" />
            </td>
            <td>
                <button id="clear" onclick="clearForm(); $('html, body').animate({ scrollTop:  $('#principalInvestigator').offset().top - 15 }); $('input').prop('disabled', false); $('select').prop('disabled', false); return false;">Clear</button>
            </td>
        </tr>
    </s:form>
    <s:hidden value="%{ongoing.siteStatus}" id="siteStatusHidden"/>
</div>

<br/>

<script type="text/javascript">
    //cargo los elementos con comportamiento collapse
    var ids = [["approvals-show-hide",true], ["followup-show-hide",true], ["inspection-show-hide",true]];
    loadCollapse(ids);
</script>
<s:if test="view">
    <script type="text/javascript">
        $('input').prop('disabled', true);
        $('select').prop('disabled', true);
    </script>
</s:if>